package com.sp.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.sp.model.entity.Bill;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 账单 Mapper
 *
 * @author tong
 * @date 2024/3/16 9:37
 */
@Mapper
public interface BillMapper extends BaseMapper<Bill> {

    /**
     * 连表分页查询
     *
     * @param page
     * @param queryWrapper
     * @return
     */
    IPage<Bill> page(IPage<Bill> page, @Param(Constants.WRAPPER) Wrapper<Bill> queryWrapper);

    /**
     * 根据id查询订单，带用户信息
     *
     * @param id
     * @return
     */
    Bill selectByIdWithUser(@Param("id") Integer id);

    /**
     * 获取指定时间内的账单数据
     *
     * @param start
     * @param end
     * @return
     */
    List<Map<String, String>> getMoneyData(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);

    /**
     * 获取指定时间内的账单数量数据
     *
     * @param start
     * @param end
     * @param status
     * @return
     */
    List<Map<String, String>> getAmountData(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end, @Param("status") String status);

}
